package com.gjy.netty.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-01-10 16:31:07
 */
public class IntegerEncoder extends MessageToByteEncoder<Integer> {

    private static final Logger logger = LoggerFactory.getLogger(IntegerEncoder.class);

    @Override
    protected void encode(ChannelHandlerContext ctx, Integer msg, ByteBuf out) throws Exception {
        out.writeInt(msg);
        logger.info("encoder msg: {}", msg);
    }
}
